from abc import ABC, abstractmethod

# 抽象产品
class Product(ABC):
    pass

# 具体产品
class ConcreteProduct1(Product):
    pass

class ConcreteProduct2(Product):
    pass

# 抽象工厂
class Factory(ABC):
    @abstractmethod
    def factory_method(self) -> Product:
        pass

# 具体工厂
class ConcreteFactory1(Factory):
    def factory_method(self) -> Product:
        return ConcreteProduct1()

class ConcreteFactory2(Factory):
    def factory_method(self) -> Product:
        return ConcreteProduct2()

# 客户端代码
def client_code(factory: Factory):
    product = factory.factory_method()
    print("Client: I'm not aware of the creator, but I've got a " + str(product) + ".")

# 测试
if __name__ == "__main__":
    print("App: Launched with the ConcreteFactory1.")
    client_code(ConcreteFactory1())
    print("\nApp: Launched with the ConcreteFactory2.")
    client_code(ConcreteFactory2())

#
#     代码实现:App: Launched with the ConcreteFactory1.
# Client: I'm not aware of the creator, but I've got a <__main__.ConcreteProduct1 object at 0x000001F0DC044E90>.
#
# App: Launched with the ConcreteFactory2.
# Client: I'm not aware of the creator, but I've got a <__main__.ConcreteProduct2 object at 0x000001F0DC044E90>.